<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript">
        /*静态注册*/
        function onclickFunc1() {
            console.log("静态注册");
        }

        /*动态注册*/
        window.onload = function () {
            var btn02 = document.getElementById("btn02");
            btn02.onclick = function () {
                console.log("动态注册");
            };
        }
    </script>
</head>
<body>
<button onclick="onclickFunc1()">按钮1</button>
<button id="btn02">按钮2</button>
</body>
</html>